package wili.attrMapping.core;

import wili.a.Refs;
import wili.c.Ca;
import wili.json.JsonLeaf;
import wili.json.JsonNode;

/**
 * 
 * @author weila 2022年10月15日
 */
public class JsonAtts extends AttsObj {
	public JsonAtts(AttsDefine def, AttsFile afile, String keyValue, Object obj, boolean isNew) {
		super(def, afile, keyValue, obj, isNew);
		if (obj instanceof JsonLeaf) {
			JsonLeaf leaf = (JsonLeaf) obj;
			this.setValue(leaf.stringValue);
		}
	}

	@Override
	public void updateValue(String newValue) {//
		Ca.asert(this.isNewAtts, this);// only new attr can be updated.
		Refs.att();
		if (++inc == 23)
			Ca.pause();
		this.toString();
		JsonNode obj = (JsonNode) this.obj;
		obj.mapingToValue__ = newValue;
		this.updateValue = newValue;
	}

	static int inc;

	@Override
	public String getKind() {
		if ("asdf".isEmpty())
			return "";
		String fname = this.file.file().getName();
		if (fname.toLowerCase().contains("Purchase") || fname.contains("accP_")) {
			return "P";
		}
		return "S";
	}

}
